home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2000 #4
/
Amiga Plus CD - 2000 - No. 4.iso
/
Tools
/
GraKa
/
VLRecNG
/
Inst
/
VLRec_NG
/
StarGate
/
Developers
/
StarGateExample.c
< prev
Wrap
C/C++ Source or Header
|
1999-12-18
|
4KB
|
138 lines
/* StarGateExample 1.0
(c) 1999 by Felix Schwarz (felix@innovative-web.de).
All rights reserved.
This sourcecode is placed in the Public Domain:
Use it for whatever you want, but don`t make
me responsible, if anything doesn`t work as
it should. This sourcecode is supplied "as is"
and I cannot be held responsible, if it causes
any damages and/or errors, loss of money, health
or whatever. Use it fully at your own risk.
The StarGate Plugin may be included into an archive
with previous permission by Felix Schwarz. Drop me
(felix@innovative-web.de) a mail and ask for a free
license.
*/
#include <stdio.h>
#include <stdlib.h>
#include <exec/ports.h>
#include <clib/exec_protos.h>
#include "stargate.h"
struct fsbitmap
{
APTR location; // Pointer to the RGB-data
long width; // width of the image to transmit
long height; // height of the image to transmit
long type; // Set this to 3
};
// Send an image to fxPAINT without saving it inbetween
BOOL sendimg_to_stargate(struct fsbitmap *fsb)
{
struct SGMessage msg;
struct Message *reply;
struct MsgPort *ReplyPort;
struct MsgPort *SGPort;
BOOL ok=FALSE;
if (ReplyPort=CreateMsgPort())
{
Forbid();
if (SGPort=FindPort("Stargate Airport"))
{
msg.msg.mn_Node.ln_Type = NT_MESSAGE;
msg.msg.mn_Length = sizeof(struct SGMessage);
msg.msg.mn_ReplyPort = ReplyPort;
msg.fsb = fsb;
PutMsg(SGPort, (struct Message *) &msg);
}
Permit();
if (SGPort)
{
Wait(1L << ReplyPort->mp_SigBit);
reply=GetMsg(ReplyPort);
ok=TRUE;
}
else
{
// Give out this (or similiar) error message here:
// "Stargate not found or fxPAINT not started"
}
DeleteMsgPort(ReplyPort);
}
return(ok);
}
// Send a filename to fxPAINT in order to fxPAINT loading that file
BOOL sendfile_to_stargate (char *file)
{
struct SGMessageExt msg;
struct Message *reply;
struct MsgPort *ReplyPort;
struct MsgPort *SGPort;
BOOL ok=FALSE;
if (ReplyPort=CreateMsgPort())
{
Forbid();
if (SGPort=FindPort("Stargate Airport"))
{
msg.msg.mn_Node.ln_Type = NT_MESSAGE;
msg.msg.mn_Length = sizeof(struct SGMessageExt);
msg.msg.mn_ReplyPort = ReplyPort;
msg.type = SG_LOAD_IMAGE;
msg.data = (APTR) file;
PutMsg(SGPort, (struct Message *) &msg);
}
Permit();
if (SGPort)
{
Wait(1L << ReplyPort->mp_SigBit);
reply=GetMsg(ReplyPort);
ok=TRUE;
}
else
{
// Give out this (or similiar) error message here:
// "Stargate not found or fxPAINT not started"
}
DeleteMsgPort(ReplyPort);
}
return(ok);
}
void main(int argc, char *argv[])
{
if (argc > 1)
{
printf("Sending %s to fxPAINT ..\n",argv[1]);
if (sendfile_to_stargate(argv[1]))
{
printf(".. sent!\n");
exit(0);
}
else
{
printf("Stargate not found or fxPAINT not running ..\n");
exit(5);
}
}
else
{
printf("Usage: StarGateExample [file]\n");
exit(5);
}
}